package com.tedu.jsd2407_ivos_fzj.geofence.controller;

import com.tedu.jsd2407_ivos_fzj.base.response.JsonResult;
import com.tedu.jsd2407_ivos_fzj.geofence.pojo.dto.GeofenceParam;
import com.tedu.jsd2407_ivos_fzj.geofence.pojo.dto.GeofenceQuery;
import com.tedu.jsd2407_ivos_fzj.geofence.pojo.vo.GeofenceVO;
import com.tedu.jsd2407_ivos_fzj.geofence.service.GeofenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/geofence")
@Slf4j
public class GeofenceController {
    @Autowired
    private GeofenceService geofenceService;
    @GetMapping("/select")
    public JsonResult select(GeofenceQuery geofenceQuery){
        log.debug("围栏查询，参数：{}",geofenceQuery);
        List<GeofenceVO> geofenceVOList = geofenceService.select(geofenceQuery);
        return JsonResult.ok(geofenceVOList);
    }
    @PostMapping("/save")
    public JsonResult save(GeofenceParam geofenceParam){
        log.debug("保存围栏，参数：{}",geofenceParam);
        geofenceService.save(geofenceParam);
        return JsonResult.ok();
    }
    @PostMapping("/deleteGeofence/{id}")
    public JsonResult deleteGeofence(@PathVariable Long id){

        geofenceService.deleteGeofence(id);
        return JsonResult.ok();
    }
}
